package verappdesktop.utils;

import java.util.ArrayList;

/**
 * Simplistic implementation of an ArrayList which disallows insertion of duplicates.
 *
 * {@inheritDoc}
 */
public class UniqueArrayList<E> extends ArrayList<E>{
	
	public UniqueArrayList(int initialSize){
		super(initialSize);
	}
	@Override
	/**
	 * Inserts the element into the list if it hasn't already been inserted.
	 * 
	 * @param e The element to be inserted.
	 * @return True if the element is inserted (isn't already in the list), false otherwise.
	 */
	public boolean add(E e){
		if (!contains(e)){
			return super.add(e);
		}
		else {
			return false;
		}
	}
}
